package cn.easier.activity.console.repository;

import cn.easier.activity.web.entity.ActivityLabel;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 标签 Repository
 */
@Repository
public interface ActivityLabelRepository extends JpaRepository<ActivityLabel, Integer> {

    @Query(value = "SELECT * FROM `activity_label` WHERE delete_flag = 0 ORDER BY sort ASC", nativeQuery = true)
    List<ActivityLabel> findAllOrderBySort();

    @Query(value = "SELECT * FROM `activity_label` WHERE parent_id IS NULL ORDER BY sort ASC", nativeQuery = true)
    List<ActivityLabel> findParents();
}
